package cn.pxs.dao;

import cn.pxs.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

@Repository
public class UserDao {
    @Autowired
    MongoTemplate mt;

    public void add(User user){
        mt.save(user);
    }

    public User findByUsername(String name){
        User u = mt.findOne(new Query(Criteria.where("name").is(name)), User.class);
        return u;
    }



}
